import ScatterChartLayer from "../../../src/chart/ScatterChartLayer";
import ScatterEffectChartLayer from "../../../src/chart/ScatterEffectChartLayer";

/**
 * 添加ChartLayer
 * @param {} earth 
 */
export function addChartLayer_Scatter(earth){

    let url = "/data/chart/scatter.json";
    fetch(url).then(resp=>{
      return resp.json();
    })
    .then(json=>{
        let layer = new ScatterChartLayer("scatter");
        earth.addLayer(layer);
        layer.setData(json.data);
    });
}

export function addChartLayer_Scatter_Effect(earth){

    let url = "/data/chart/scatter.json";
    fetch(url).then(resp=>{
      return resp.json();
    })
    .then(json=>{
        let layer = new ScatterEffectChartLayer("scatter");
        earth.addLayer(layer);
        layer.setData(json.data);
    });    
}

function getSampleData(){
    let data = [{
        "name": "北京",
        "value": [116.46, 39.92, 20259]
    }, {
        "name": "上海",
        "value": [121.48, 31.22, 19780]
    }, {
        "name": "广州",
        "value": [113.23, 23.16, 15769]
    }, {
        "name": "成都",
        "value": [104.06, 30.67, 13873]
    }, {
        "name": "重庆",
        "value": [106.54, 29.59, 13283]
    }, {
        "name": "武汉",
        "value": [114.31, 30.52, 8678]
    }, {
        "name": "天津",
        "value": [117.2, 39.13, 8626]
    }, {
        "name": "深圳",
        "value": [114.07, 22.62, 8259]
    }, {
        "name": "西安",
        "value": [108.95, 34.27, 6991]
    }, {
        "name": "南京",
        "value": [118.78, 32.04, 6959]
    }, {
        "name": "苏州",
        "value": [120.62, 31.32, 6707]
    }, {
        "name": "郑州",
        "value": [113.65, 34.76, 6690]
    }, {
        "name": "青岛",
        "value": [120.33, 36.07, 6667]
    }, {
        "name": "石家庄",
        "value": [114.48, 38.03, 6137]
    }, {
        "name": "佛山",
        "value": [113.11, 23.05, 5741]
    }, {
        "name": "杭州",
        "value": [120.19, 30.26, 5632]
    }, {
        "name": "长沙",
        "value": [113, 28.21, 5303]
    }, {
        "name": "昆明",
        "value": [102.73, 25.04, 4633]
    }, {
        "name": "福州",
        "value": [119.3, 26.08, 4542]
    }, {
        "name": "沈阳",
        "value": [123.38, 41.8, 4540]
    }, {
        "name": "济南",
        "value": [117, 36.65, 4361]
    }, {
        "name": "太原",
        "value": [112.53, 37.87, 4080]
    }, {
        "name": "合肥",
        "value": [117.27, 31.86, 4039]
    }, {
        "name": "无锡",
        "value": [120.29, 31.59, 3393]
    }, {
        "name": "厦门",
        "value": [118.1, 24.46, 3329]
    }, {
        "name": "大连",
        "value": [121.62, 38.92, 3202]
    }, {
        "name": "南宁",
        "value": [108.33, 22.84, 3157]
    }, {
        "name": "哈尔滨",
        "value": [126.63, 45.75, 3141]
    }, {
        "name": "东莞",
        "value": [113.75, 23.04, 3030]
    }, {
        "name": "南昌",
        "value": [115.89, 28.68, 3025]
    }, {
        "name": "长春",
        "value": [125.35, 43.88, 3016]
    }, {
        "name": "海口",
        "value": [110.35, 20.02, 2568]
    }, {
        "name": "珠海",
        "value": [113.52, 22.3, 2186]
    }, {
        "name": "惠州",
        "value": [114.4, 23.09, 1973]
    }, {
        "name": "昆山",
        "value": [120.95, 31.39, 1894]
    }, {
        "name": "三亚",
        "value": [109.31, 18.14, 1135]
    }];
    
    return data;
}